﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KeMei.Common;

public partial class Manager_contactUs_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserInfo"] == null)
        {
            Response.Redirect(ConfigHelper.SystemUrl + "Manager/login.aspx", true);

        }
        if (!IsPostBack)
        {
            InitModel(1);
        }
    }

    /// <summary>
    /// 绑定实体类到控件
    /// </summary>
    protected void InitModel(int ID)
    {
        KeMei.Model.AboutUs model = null;
        KeMei.BLL.AboutUs bll = new KeMei.BLL.AboutUs();

        try
        {
            model = bll.GetModel(ID);

            if (model != null)
            {
                txtcontent.Value = model.TContent;
            }
        }
        catch (Exception ex)
        {

            ExtAspNet.Alert.Show("初始化实体类失败：" + ex.Message);
        }
    }

    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        KeMei.BLL.AboutUs bll = new KeMei.BLL.AboutUs();
        KeMei.Model.AboutUs model = new KeMei.Model.AboutUs();

        try
        {
            if (string.IsNullOrEmpty(txtcontent.Value))
            {
                ExtAspNet.Alert.Show("请填写联系信息");
                return;
            }   

            model.lmID = 5;
            model.TContent = txtcontent.Value;
            model.Recorddate = DateTime.Now;

            model.ID = 1;

            bll.Update(model);

            ExtAspNet.Alert.Show("保存成功！", String.Empty, ExtAspNet.Alert.DefaultIcon);
        }
        catch (Exception ex)
        {
            ExtAspNet.Alert.Show("保存失败：" + ex.Message);
        }
    }
}